﻿using System;
using System.ComponentModel;
using System.Linq;
using ProjectEuler.Linq;

namespace ProjectEuler.Problems
{
    [EulerProblem(48, 9110846700ul)]
    [Description("Find the last ten digits of 1^1 + 2^2 + ... + 1000^1000.")]
    internal sealed class Problem048 : EulerProblem
    {
        private const UInt64 TenDigits = 10000000000ul;

        public override Object Solve()
        {
            var result = 0UL;

            for (var i = 1ul; i <= 1000; i++)
            {
                var tmp = i;

                for (var j = 1ul; j < i; j++)
                {
                    tmp *= i;
                    tmp %= TenDigits;
                }

                result += tmp;
            }

            return result % TenDigits;
        }
    }
}
